import { h } from 'vue'
const deposit = {
    index: true,
    border: true,
    stripe: true,
    menuAlign: 'center',
    loadingText: "加载中...",
    loadingSpinner: "svg",
    loadingSvgViewBox: "-10, -10, 50, 50",
    loadingBackground: "rgba(122, 122, 122, 0.6)",
    menu: true,
    menuWidth: 60,
    addBtn: false,
    delBtn: false,
    editBtn: false,
    column: [
        {
            label: "订单号",
            prop: "orderId",
            minWidth: 100,
            search: true
        },
        {
            label: '用户ID',
            prop: 'userId',
            minWidth: 100,
            search: true
        },
        {
            label: '手机号',
            prop: 'mobile',
            minWidth: 100,
            search: true
        },
        {
            label: '发起金额',
            prop: 'payAmount',
            minWidth: 100,
            formatter: (row, value, column) => {
                return row.payAmount / 100
            }
        },
        {
            label: '税后金额',
            prop: 'payAmount',
            minWidth: 100,
            formatter: (row, value, column) => {
                // 税后金额 = 发起金额-  发起金额 * 0.05 不足1 扣1
                const amount = row.payAmount / 100;
                return amount > 1 ? amount * 0.95 : amount - 1;
            }
        },
        {
            label: '充值金额',
            prop: 'amount',
            minWidth: 100,
            formatter: (row, value, column) => {
                return row.amount / 100
            }
        },
        {
            label: '充值渠道',
            prop: 'channel',
            minWidth: 100
        },
      
        {
            label: '充值时间',
            prop: 'updatedAt',
            minWidth: 100,
            formatter: (row, value, column) => {
                return formatDate(row.updatedAt * 1000, '-')
            }
        },
        {
            label: '状态',
            prop: 'status',
            minWidth: 0,
            search: true,
            searchType: "select",
            dicData: [
                {
                    label: '待支付',
                    value: 1
                },
                {
                    label: '已完成',
                    value: 2
                },
                {
                    label: '超时',
                    value: 3
                },
                {
                    label: '失败',
                    value: 4
                },
            ],
            formatter: (row, value, column) => {
                if(row.status > 100){
                    return `状态${(row.status - 10000) / 100}`
                }
                return row.status === 1 ? '待支付' : row.status === 2 ? '已完成' : row.status === 3 ? '超时' : '失败'
            },
            // render: (params) => {
            //     console.log('params=>>',params)
            //     let color = 'red';
            //     let text = params.column.formatter(params.row)
            //     if(text == '待支付'){
            //         color = '#0011ff'
            //     }else if(text == '已完成'){
            //         color = 'rgb(56 157 60)'
            //     }else if(text == '超时'){
            //         color = 'red'
            //     }else{
            //         color = '#f00'
            //     }
            //     return h('span',
            //         {
            //             attrs: { id: 'box' },
            //             class: { 'demo': true },
            //             style: { color: color, },
            //         }, text)
            // }
        },
    ],
}

const formatDate = (date, cut) => {
    var date = new Date(date);
    var YY = date.getFullYear() + cut;
    var MM =
        (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + cut;
    var DD = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
    var hh = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
    var mm = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
    var ss = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
    return YY + MM + DD + " " + hh + mm + ss;
};

export default deposit